package com.miyake.dsp.osa.lab.wrapper;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.ArrayUtils;

import com.miyake.dsp.ComplexArray;
import com.miyake.dsp.ScilabExecute;
import com.miyake.dsp.osa.lab.Calculator;
import com.miyake.dsp.osa.lab.Convolution2;
import com.miyake.dsp.osa.lab.LabUiAnnotation;
@LabUiAnnotation(caption="Unsharp Mask Filter")
public class UnsharpMaskWrapper extends Calculator {
	public static final String INPUT = "Input";
	public static final String OUTPUT = "Output";
	public static final String OUTPUT_LAPLACIAN = "Laplacian";
	
	public UnsharpMaskWrapper() {
		initInput(INPUT);
		initOutput(OUTPUT);
		initOutput(OUTPUT_LAPLACIAN);
	}
	
	@Override
	public void process() {
		double[] lapOp = { -2, 4, -2};
		double[] data1 = getInput(INPUT).getRealPart();
		ComplexArray ret = ScilabExecute.execute("ret=convol(data1,data2);", new ComplexArray(lapOp), new ComplexArray(data1), "ret");
		
		setOutput(OUTPUT_LAPLACIAN, ret);
		

		ComplexArray ret2 = ScilabExecute.execute("ret=data1-data2", 
				new ComplexArray(data1), 
				new ComplexArray(ArrayUtils.subarray(ret.getRealPart(), 0, ret.getRealPart().length-lapOp.length+1)), 
				"ret");
		setOutput(OUTPUT, ret2);
	}

	@Override
	public Object getSetting() {
		// TODO Auto-generated method stub
		return null;
	}

}
